<ul class="star">
    <li id="start_1"><i class="iconfont icon-start_black"></i></li>
    <li id="start_2"><i class="iconfont icon-start_black"></i></li>
    <li id="start_3"><i class="iconfont icon-start_black"></i></li>
    <li id="start_4"><i class="iconfont icon-start_black"></i></li>
    <li id="start_5"><i class="iconfont icon-start_black"></i></li>
</ul>
<textarea placeholder="请输入服务评价" class="textarea" cols="30" rows="10" id="content"></textarea>
<input type="hidden" name="start" id="start" value="0">
<p class="oper" id="oper">
    <button class="btn" id="back">返回</button>
    <button class="btn btn_info" id="commit">提交评价</button>
</p>
<section class="alert">
    <section class="error msg_cont">
        <i class="iconfont icon-shibai error"></i>
        <h1>提交失败</h1>
    </section>
    <section class="warn msg_cont">
        <i class="iconfont icon-tishi warn"></i>
        <h1>评价内容不能为空</h1>
    </section>
    <section class="success msg_cont">
        <i class="iconfont icon-chenggong success"></i>
        <h1>提交成功</h1>
    </section>
</section>
<script>
    $(function () {
        $(".star").on('click', 'li', function () {
            var id = $(this).prop('id');
            var num = id.split('_')[1]
            $("input[name='start']").val(num * 20)
            $(".star").find("li i").removeClass('icon-start_selected').addClass('icon-start_black')
            for (var i = 1; i < num * 1 + 1; i++) {
                $("#start_" + i + " i").addClass('icon-start_selected').removeClass('icon-start_black')
            }
        })
        // 路由跳转
        $("#oper").on('click', '.btn', function () {
            var id = $(this).attr('id');
            if (id === 'back') {
                $('#main').load('./person.html');
            } else {
                var value = $("#content").val();
                if (!value) {
                    msgHShowOrHide('.warn')
                } else {
                    $.ajax({
                        url: getHost() + "/xboot/enforceLawStatisfaction/add",
                        dataType: "json",
                        async: true,
                        data: {
                            "objectId": getQueryString('governmentNo'),
                            'objectType': getQueryString('type'),
                            "score": $("#start").val(),
                            "content": $("#content").val()
                        },
                        type: "POST",
                        beforeSend: function () {
                            $(".mask").show();
                        },
                        success: function (req) {
                            $(".mask").hide();
                            msgHShowOrHide('.success');
                            setTimeout(function () {
                                $('#main').load('./person.html');
                            }, 1500)
                        },
                        error: function () {
                            msgHShowOrHide('.error')
                        }
                    });
                }
            }
        })
    })
</script>